/**
 * @RpcNode.java  COPYRIGHT xiaojian
 * 
 * Created on 2017年1月5日 下午4:19:08
 */
package xj.toolkit.rpc.naming;

import java.io.Serializable;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.google.common.base.Preconditions;

/**
 * RPC节点。
 * 
 * @author <a href="mailto:cxj2000@gmail.com">xiaojian.cao</a>
 *
 */
public class RpcNode implements Serializable {
	
	private static final long serialVersionUID = -7845348786779453452L;

	private String name = null;

	/**
	 * 节点所在的ip地址。
	 */
	private String ipAddress = null;

	/**
	 * 节点所在的端口。
	 */
	private int port = 0;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIpAddress() {
		return ipAddress;
	}

	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
	
	public boolean equals(Object other) {
		Preconditions.checkArgument(other != null);
		if (other instanceof RpcNode) {
			return this.getName().equals(((RpcNode)other).getName());
		}
		
		return false;
	}
}
